const { SocialiteManager } = require('node-socialite');
const express = require("express");
const Router = express.Router;
const router = new Router();


let manager = new SocialiteManager({
    qq: {
        client_id: '101454130',
        client_secret: '60643bd14dbf0fd5be6c7f7ca9a97d53',
        redirect: 'http://nb.local/qq'
    },
});

router.get('/qq-login', (req, res) => {
    //跳转的 url
    let url = manager.create('qq').redirect();
    res.redirect(url);
});

router.get('/qq', async (req, res) => {
    console.log(222);
    let code = req.query.code;
    let user = await manager.create('qq').userFromCode(code);
    console.log(user);
    res.json(user);
});


module.exports = router;